/******************************************************************************
*
* MODULE:    Counter.v
* DEVICE:     
* PROJECT:   Tarea 1 Diseño Electronico Digital
* AUTHOR:    Ricardo Dávila Castro   
* DATE:      2010 19:35:08
*
* ABSTRACT:  Contador Asc/DEsc Ejercicio 4
*            
*******************************************************************************/

`ifndef 	COUNTER
`define    COUNTER


module Counter (
input clk,
input rst,
input [3:0] EntradaParalela,
input Captura,
input Direccion,
output [3:0] CuentaNumero
);

reg [3:0] numCuenta =0;

always @ (posedge clk, posedge rst)
	begin
		 if (rst)
		 numCuenta <= 0;
		 else
		 		if (Captura)
		 		 	numCuenta <= EntradaParalela;
		  		else if (Direccion)
		  			numCuenta <= numCuenta+1;
		  		else 
		 			numCuenta <= numCuenta-1;
		
		 
	end

assign CuentaNumero = numCuenta;

endmodule

`endif